/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package org.vale.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Gabriel Bran gbran.u@gmail.com
 */
@Entity
@Table(name = "form_question")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "FormQuestion.findAll", query = "SELECT f FROM FormQuestion f"),
    @NamedQuery(name = "FormQuestion.findByIdQuestion", query = "SELECT f FROM FormQuestion f WHERE f.idQuestion = :idQuestion"),
    @NamedQuery(name = "FormQuestion.findByQuestionType", query = "SELECT f FROM FormQuestion f WHERE f.questionType = :questionType"),
    @NamedQuery(name = "FormQuestion.findByQuestion", query = "SELECT f FROM FormQuestion f WHERE f.question = :question"),
    @NamedQuery(name = "FormQuestion.findByFeedback", query = "SELECT f FROM FormQuestion f WHERE f.feedback = :feedback")})
public class FormQuestion implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_question")
    private Integer idQuestion;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 1)
    @Column(name = "question_type")
    private String questionType;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 512)
    @Column(name = "question")
    private String question;
    @Size(max = 255)
    @Column(name = "feedback")
    private String feedback;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idQuestion")
    private List<EvaluationForm> evaluationFormList;
    @JoinColumn(name = "id_form", referencedColumnName = "id_form")
    @ManyToOne(optional = false)
    private FormTemplate idForm;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idQuestion")
    private List<AnswerChoise> answerChoiseList;

    public FormQuestion() {
    }

    public FormQuestion(Integer idQuestion) {
        this.idQuestion = idQuestion;
    }

    public FormQuestion(Integer idQuestion, String questionType, String question) {
        this.idQuestion = idQuestion;
        this.questionType = questionType;
        this.question = question;
    }

    public Integer getIdQuestion() {
        return idQuestion;
    }

    public void setIdQuestion(Integer idQuestion) {
        this.idQuestion = idQuestion;
    }

    public String getQuestionType() {
        return questionType;
    }

    public void setQuestionType(String questionType) {
        this.questionType = questionType;
    }

    public String getQuestion() {
        return question;
    }

    public void setQuestion(String question) {
        this.question = question;
    }

    public String getFeedback() {
        return feedback;
    }

    public void setFeedback(String feedback) {
        this.feedback = feedback;
    }

    @XmlTransient
    public List<EvaluationForm> getEvaluationFormList() {
        return evaluationFormList;
    }

    public void setEvaluationFormList(List<EvaluationForm> evaluationFormList) {
        this.evaluationFormList = evaluationFormList;
    }

    public FormTemplate getIdForm() {
        return idForm;
    }

    public void setIdForm(FormTemplate idForm) {
        this.idForm = idForm;
    }

    @XmlTransient
    public List<AnswerChoise> getAnswerChoiseList() {
        return answerChoiseList;
    }

    public void setAnswerChoiseList(List<AnswerChoise> answerChoiseList) {
        this.answerChoiseList = answerChoiseList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idQuestion != null ? idQuestion.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof FormQuestion)) {
            return false;
        }
        FormQuestion other = (FormQuestion) object;
        if ((this.idQuestion == null && other.idQuestion != null) || (this.idQuestion != null && !this.idQuestion.equals(other.idQuestion))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.vale.entity.FormQuestion[ idQuestion=" + idQuestion + " ]";
    }
    
}
